package net.cyndeline.events.actions

import net.cyndeline.entitySystem.Event
import net.cyndeline.entitySystem.EntityRef
import com.escalatesoft.subcut.inject.BindingModule
import com.escalatesoft.subcut.inject.Injectable
import net.cyndeline.entitySystem.defaultImpl.DefaultEntityRef

/**
 * Attempts to steal an item, transferring it from one entity
 * to another.
 */
trait StealEvent extends Event {
  
  /** The entity attempting to steal. */
  def thief: EntityRef
  
  /** Sets a new thieving entity. */
  def thief_=(newThief: EntityRef)
}

class Steal(implicit val bindingModule: BindingModule) extends StealEvent with Injectable {
  
  override var thief: EntityRef = injectOptional[EntityRef] getOrElse new DefaultEntityRef()
  
  override def copy = {
    val copy = new Steal()
    
    /* Note that the thief isn't copied. */
    copy.thief = thief
    copy
  }
  
  override def +(other: Event) = {
    copy
  }
}